<?php

namespace Admin\Controller;

use Common\Util\BaseData;
use Common\Util\UserData;
use Common\Util\Wxrcode;

class AgentController extends AdminController{

	public function applyAgent(){
		$map = [];
		if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
			$s_keyword = trim($_GET['keyword']);
			$map['agent_name|agent_phone'] = ['like', "%$s_keyword%"];
		}
		$list = $this->lists('AgentApply', $map, 'id Asc', true, 20);
		$this->assign('list', $list);
		$this->assign('getting', $_GET);
		$this->display('index');
	}

	public function setStatus(){
		$field = I('get.field');
		$status = I('get.status');
		$aid = I('get.aid');
		$t_agent_apply = M("agent_apply");
		$data['id'] = $aid;
		$data[$field] = $status;
		$data['update_time'] = time();
		if($t_agent_apply->save($data)){
			$this->return_json_data(1, '更新成功');
		}else{
			$this->return_json_data(0, '更新失败');
		}
	}
}
